package main

import (
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
)

func main() {
	db, err := sql.Open("mysql", "root:123456@tcp(39.108.187.254:3306)/tornado?charset=utf8")
	CheckErr(err)
	rows, err := db.Query("select * from student")
	CheckErr(err)
	for rows.Next() {
		var s_name string
		var s_age int
		var id int
		err = rows.Scan(&id, &s_name, &s_age)
		CheckErr(err)
		fmt.Println(s_name)
		fmt.Println(s_age)
		fmt.Println(id)
	}
	db.Close()
}

func CheckErr(err error) {
	if err != nil {
		panic(err)
	}
}
